package com.time.company.app;

import com.time.company.R;

/**
 * 地址的管理类
 * Author: Created by XuHan on 2016/12/26.
 */

public class AddressManager {

    private volatile static AddressManager mInstance;

    // 全局地址
    private static final String ADDRESS = "address";

    // 全局web地址
    private static final String WEB_ADDRESS = "web_address";

    // 我的地址
    private static final String PROFILE_ADDRESS = "profileAddress";

    // 头像上传地址
    private static final String UPLOAD_ADDRESS = "upload_address";

    // 启动页
    private static final String LAUNCH_PAGE_ADDRESS = "launch_page_address";

    // 用户注册协议
    private static final String USER_REGISTER_PROTOCOL_ADDRESS = "user_register_protocol_address";

    // 公司注册协议
    private static final String COMPANY_REGISTER_PROTOCOL_ADDRESS = "company_register_protocol_address";

    // 客服热线
    private static final String CUSTOMER_SERVICE_TELEPHONE_NUMBERS = "customer_service_telephone_numbers";

    public static AddressManager getInstance() {
        if (mInstance == null) {
            synchronized (AddressManager.class) {
                if (mInstance == null) {
                    mInstance = new AddressManager();
                }
            }
        }
        return mInstance;
    }

    public String getAddress() {
        String defaultAddress = new StringBuilder().append(MyApplication.getInstance().getString(R.string.web_service_base_url_init)).toString();
        return AppConfig.getInstance().getString(ADDRESS, defaultAddress);
    }

    public void setAddress(String address) {
        StringBuilder service = new StringBuilder().append(address).append("service");
        AppConfig.getInstance().putString(ADDRESS, service.toString());
    }


    public String getWebAddress(){
        return AppConfig.getInstance().getString(WEB_ADDRESS, "");
    }

    public void  setWebAddress(String webAddress){
        AppConfig.getInstance().putString(WEB_ADDRESS, webAddress);
    }


    public String getProfileAddress() {
        return AppConfig.getInstance().getString(PROFILE_ADDRESS, "");
    }

    public void setProfileAddress(String address) {
        AppConfig.getInstance().putString(PROFILE_ADDRESS, address);
    }

    public String getUploadAddress() {
        return AppConfig.getInstance().getString(UPLOAD_ADDRESS, "");
    }

    public void setUploadAddress(String uploadAddress) {
        AppConfig.getInstance().putString(UPLOAD_ADDRESS, uploadAddress);
    }

    public String getLaunchPageAddress() {
        return AppConfig.getInstance().getString(LAUNCH_PAGE_ADDRESS, "");
    }

    public void setLaunchPageAddress(String launchPageAddr) {
        AppConfig.getInstance().putString(LAUNCH_PAGE_ADDRESS, launchPageAddr);
    }

    public String getUserRegisterProtocolAddress(){
        return AppConfig.getInstance().getString(USER_REGISTER_PROTOCOL_ADDRESS, "");
    }

    public void setUserRegisterProtocolAddress(String userProtocol){
        AppConfig.getInstance().putString(USER_REGISTER_PROTOCOL_ADDRESS, userProtocol);
    }


    public String getCompanyRegisterProtocolAddress(){
        return AppConfig.getInstance().getString(COMPANY_REGISTER_PROTOCOL_ADDRESS, "");
    }

    public void setCompanyRegisterProtocolAddress(String companyProtocol){
        AppConfig.getInstance().putString(COMPANY_REGISTER_PROTOCOL_ADDRESS, companyProtocol);
    }

    public String getCustomerServiceTelephoneNumbers(){
        return AppConfig.getInstance().getString(CUSTOMER_SERVICE_TELEPHONE_NUMBERS, "");
    }

    public void setCustomerServiceTelephoneNumbers(String telephone){
        AppConfig.getInstance().putString(CUSTOMER_SERVICE_TELEPHONE_NUMBERS, telephone);
    }

}
